package cn.gok.happymallgroup01.util;

/**
 * @Author: chenfan
 * @Description: 自定义的响应结果集
 */
public class ResultData<T> {

    /**
     * 响应状态码
     */
    private String status;

    /**
     * 响应的数据
     */
    private T data;

    /**
     * 响应的提示信息
     */
    private String msg;

    public ResultData() {
    }

    public ResultData(String status, T data, String msg) {
        this.status = status;
        this.data = data;
        this.msg = msg;
    }

    public static ResultData success(){
        return new ResultData(ResponseCode.SUCCESS.getCode(),null,ResponseCode.SUCCESS.getMsg());
    }
    /**
     *
     * @param msg
     * @return
     */
    public static ResultData success(String msg){
        return new ResultData(ResponseCode.SUCCESS.getCode(),null,msg);
    }

    public static<T> ResultData createData(T data){
        return new ResultData(ResponseCode.SUCCESS.getCode(),data,ResponseCode.SUCCESS.getMsg());
    }


    public static ResultData fail(){
        return new ResultData(ResponseCode.FAIL.getCode(),null,ResponseCode.FAIL.getMsg());
    }

    public static ResultData fail(String msg){
        return new ResultData(ResponseCode.FAIL.getCode(),null,msg);
    }

}
